import 'package:json_annotation/json_annotation.dart';

part 'socket_entity.g.dart';

@JsonSerializable()
class SocketEntity {
  /// 会话ID
  @JsonKey(name: "conv_id")
  String? convId;

  /// 会话类型
  /// 用于区分单聊、群聊等不同类型的会话
  @JsonKey(name: "conv_type")
  int? convType;

  /// 消息内容
  @JsonKey(name: "msg_content")
  dynamic? msgContent;

  /// 消息内容格式
  /// 1: JSON格式
  /// 2: Protobuf格式
  @JsonKey(name: "msg_content_fmt")
  int? msgContentFmt;

  /// 消息内容类型
  /// 可选值：text, image, audio, video, file等
  /// 支持扩展新的类型
  @JsonKey(name: "msg_content_type")
  String? msgContentType;

  /// 消息类型
  @JsonKey(name: "msg_type")
  String? msgType;

  /// 消息发送时间
  @JsonKey(name: "send_timestamp")
  int? sendTimeStamp;

  /// 发送者头像URL
  @JsonKey(name: "sender_avatar")
  String? senderAvatar;

  /// 发送者ID
  @JsonKey(name: "sender_id")
  String? senderId;

  /// 发送者昵称
  @JsonKey(name: "sender_nick")
  String? senderNick;

  /// 默认构造函数
  SocketEntity({
    this.convId,
    this.convType,
    this.msgContent,
    this.msgContentFmt,
    this.msgContentType,
    this.msgType,
    this.sendTimeStamp,
    this.senderAvatar,
    this.senderId,
    this.senderNick,
  });

  /// 从JSON映射创建消息实体对象
  factory SocketEntity.fromJson(Map<String, dynamic> json) => _$SocketEntityFromJson(json);

  /// 将消息实体对象转换为JSON映射
  Map<String, dynamic> toJson() => _$SocketEntityToJson(this);
}
